package com.baizhi.chario;

import java.io.FileWriter;
import java.io.FilterWriter;
import java.io.IOException;

/**
 *  字符过滤流，
 */
public class FileterWriterDemo {
    public static void main(String[] args) throws IOException {
        FileWriter fw = new FileWriter("./javase_io/b.text");

        FilterWriter fw2 = new FilterWriter(fw){
            //打印所有姓张的同学
            public void write(String name) throws IOException {
               if(name.startsWith("张")){

                   fw.write(name);
               }
            }
        };


        fw2.write("张三丰");
        fw2.write("李四");
        fw2.write("张三");
        fw2.write("陈才");

        fw2.close();


    }
}


// 文件字符流
class FileWriterDemo{
    public static void main(String[] args) throws IOException {
        /**
         * 可以直接写出字符
         */
        FileWriter fw = new FileWriter("./javase_io/a.text");
        fw.write("李白乘舟将欲行，忽闻岸上踏歌声，桃花潭水深千尺，不及汪伦送我情");

        fw.close();
    }
}
